package sample2;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JButton;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import javax.swing.JTextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Date;
import java.awt.event.WindowEvent;
import java.awt.event.WindowAdapter;

public class Frame1 extends JFrame {
    JPanel contentPane;
    XYLayout xYLayout1 = new XYLayout();
    JButton jButton1 = new JButton();
    JTextField jTextField1 = new JTextField();
    JButton jButton2 = new JButton();
    JTextField jTextField_ZipFileName = new JTextField();
    JTextField jTextField_ExecuteFileName = new JTextField();
    public Frame1() {
        try {
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    /**
     * Component initialization.
     *
     * @throws java.lang.Exception
     */
    private void jbInit() throws Exception {
        contentPane = (JPanel) getContentPane();
        contentPane.setLayout(xYLayout1);
        setSize(new Dimension(400, 300));
        this.setState(java.awt.Frame.ICONIFIED);
        setTitle("JWS4Native");
        this.addWindowListener(new Frame1_this_windowAdapter(this));
        jButton1.setText("jButton1");
        jButton1.addActionListener(new Frame1_jButton1_actionAdapter(this));
        jTextField1.setText("jTextField1");
        jButton2.setText("jButton2");
        jButton2.addActionListener(new Frame1_jButton2_actionAdapter(this));
        jTextField_ZipFileName.setText("jTextField2");
        jTextField_ExecuteFileName.setText("jTextField2");
        contentPane.add(jTextField1, new XYConstraints(64, 31, 214, 47));
        contentPane.add(jButton1, new XYConstraints(136, 86, 113, 38));
        contentPane.add(jButton2, new XYConstraints(115, 198, 112, 31));
        contentPane.add(jTextField_ZipFileName,
                        new XYConstraints(61, 129, 219, 35));
        contentPane.add(jTextField_ExecuteFileName,
                        new XYConstraints(60, 168, 221, 24));
    }

    public void jButton1_actionPerformed(ActionEvent actionEvent) {
        jTextField1.setText(new Date().toString());
    }

    public void jButton2_actionPerformed(ActionEvent e) {
        System.loadLibrary("sysutil");

        String zipFileName = jTextField_ZipFileName.getText();
        String appFileName = jTextField_ExecuteFileName.getText();

        com.bluesky.system.NativeRunner.execApp(zipFileName, appFileName);
    }

    public void this_windowOpened(WindowEvent e) {

        if (Application1.gArgs.length >= 2) {
            String zipFileName = Application1.gArgs[0];
            String appFileName = Application1.gArgs[1];

            com.bluesky.system.NativeRunner.execApp(zipFileName, appFileName);
            System.exit(0);
        }
    }

}


class Frame1_this_windowAdapter extends WindowAdapter {
    private Frame1 adaptee;
    Frame1_this_windowAdapter(Frame1 adaptee) {
        this.adaptee = adaptee;
    }

    public void windowOpened(WindowEvent e) {
        adaptee.this_windowOpened(e);
    }
}


class Frame1_jButton2_actionAdapter implements ActionListener {
    private Frame1 adaptee;
    Frame1_jButton2_actionAdapter(Frame1 adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton2_actionPerformed(e);
    }
}


class Frame1_jButton1_actionAdapter implements ActionListener {
    private Frame1 adaptee;
    Frame1_jButton1_actionAdapter(Frame1 adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent actionEvent) {
        adaptee.jButton1_actionPerformed(actionEvent);
    }
}
